import { createApp } from 'vue';
import App from './App.vue';
import router from './router';
import store from './store';
import '@/myAxios/myAxios';
import ElementPlus from 'element-plus';
import zhCn from 'element-plus/es/locale/lang/zh-cn';

//解决周选择器从周日开始的问题
import "dayjs/locale/zh-cn";

//#region 解决ElementPlus表格报错 ResizeObserver loop limit exceeded 问题
const debounce = (fn, delay) => {
    let timer = null;
    return function () {
        let context = this;
        let args = arguments;
        clearTimeout(timer);
        timer = setTimeout(function () {
            fn.apply(context, args);
        }, delay);
    };
};

const _ResizeObserver = window.ResizeObserver;
window.ResizeObserver = class ResizeObserver extends _ResizeObserver {
    constructor(callback) {
        callback = debounce(callback, 16);
        super(callback);
    }
};
//#endregion

createApp(App).use(store).use(router).use(ElementPlus, {
    locale: zhCn,
}).mount('#app');
